package com.watson.juc.testlist;

import java.util.ArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

/**
 * @author watson
 * @date 2021/7/30 14:21
 * @Description: TODO
 **/
public class ThreadPoolDemo {
    public static void main(String[] args) {
        System.out.println(Runtime.getRuntime().availableProcessors());

        //Function函数型接口,有一个输入多数，有一个输出只要是函数型接口
        // 可以用Lambda表达式简化

        Function<String, String> function = new Function<String, String>() {
            @Override
            public String apply(String str) {
                return str;
            }
        };

        Function<String, String> function1 = (o) -> {
            return o;
        };

//        System.out.println(function.apply("s"));


        //断定型接口:有一个输入参数,返回值只能是布尔信!|
        Predicate<String> predicate = new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.isEmpty();
            }
        };

        Predicate<String> predicate1 = (d) -> {
            return d.isEmpty();
        };

        Consumer<String> consumer = new Consumer<String>() {
            @Override
            public void accept(String o) {
                System.out.println(o);
            }

        };

        Consumer<String> consumer1 = (o) -> {
            System.out.println(o);
        };


        Supplier<String> supplier = new Supplier() {
            @Override
            public Object get() {
                System.out.println("get");
                return "1024";
            }
        };
        Supplier<String> supplier1 = () -> {
            System.out.println("get");
            return "1024";
        };


    }
}
